﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmPedido.aspx.cs" Inherits="Presentacion.frmPedido" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">


    <fieldset>
    <legend>Pedido</legend>

        <table cellpadding="2">
            <tr>
                <td>
                    Codigo:</td>
                <td>
                    <asp:TextBox ID="txtId" runat="server" Enabled="False">0</asp:TextBox>
                </td>
                <td>
                    Fecha:</td>
                <td>
                    <asp:TextBox ID="txtFecha" runat="server" Enabled="False"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Empleado</td>
                <td>
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                        <ContentTemplate>
                            <asp:TextBox ID="txtEmpleado" runat="server" Enabled="False"></asp:TextBox>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="gvEmpleado" 
                                EventName="SelectedIndexChanged" />
                        </Triggers>
                    </asp:UpdatePanel>
                </td>
                <td>
                    <asp:Button ID="btnEmpleado" runat="server" Text="Empleado" Width="93px" 
                        Visible="False" />
                </td>
                <td>
                    <asp:Button ID="btnProveedor" runat="server" Text="Proveedor" Width="86px" />
                </td>
            </tr>
        </table>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <table cellpadding="2">
                    <tr>
                        <td>
                            Razon Social</td>
                        <td>
                            <asp:TextBox ID="txtProveedorNomb" runat="server" Enabled="False"></asp:TextBox>
                        </td>
                        <td>
                            RUC:</td>
                        <td>
                            <asp:TextBox ID="txtProveedorRuc" runat="server" Enabled="False"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Dirección:</td>
                        <td>
                            <asp:TextBox ID="txtProveedorDirección" runat="server" Enabled="False"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                </table>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="gvProveedor" 
                    EventName="SelectedIndexChanged" />
            </Triggers>
        </asp:UpdatePanel>
        
        <asp:UpdatePanel ID="UpdatePanel8" runat="server">
            <ContentTemplate>
                Total:<asp:Label ID="lblTotal" runat="server"></asp:Label>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnAgregar" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
        
        <asp:Button ID="btnGuardar" runat="server" Text="Guardar" 
            onclick="btnGuardar_Click" />
        &nbsp;&nbsp;
        
        <asp:Button ID="btnDesactivar" runat="server" onclick="btnDesactivar_Click" 
            Text="Desactivar" Visible="False" />
        
    </fieldset>

<!-- ####################################### -->

    <asp:UpdatePanel ID="UpdatePanel3" runat="server">
    <ContentTemplate>
    <fieldset>
    <legend>Producto</legend>

        <asp:Label ID="lblMensaje" runat="server" ForeColor="Red"></asp:Label>
        <table cellpadding="2">
            <tr>
                <td>
                    Codigo:</td>
                <td>
                    <asp:TextBox ID="txtProductoId" runat="server" Width="106px"></asp:TextBox>
                    <asp:Button ID="btnBuscaProdId" runat="server" onclick="btnBuscaProdId_Click" 
                        Text="..." />
                </td>
                <td>
                    Producto:</td>
                <td>
                    <asp:TextBox ID="txtProductoDesc" runat="server" Enabled="False"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Cantidad:</td>
                <td>
                    <asp:TextBox ID="txtProductoCant" runat="server"></asp:TextBox>
                </td>
                <td>
                    Precio:</td>
                <td>
                    <asp:TextBox ID="txtProductoPrec" runat="server" Enabled="False"></asp:TextBox>
                </td>
            </tr>
        </table>

    </fieldset>
    </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="gvProducto" 
                EventName="SelectedIndexChanged" />
            <asp:AsyncPostBackTrigger ControlID="btnBuscaProdId" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
    <asp:Button ID="btnAgregar" runat="server" Text="Agregar" 
        onclick="btnAgregar_Click" />
    <asp:Button ID="btnBuscarProducto" runat="server" Text="Buscar Producto" />
    <br />

<!-- ####################################### -->

    <asp:UpdatePanel ID="UpdatePanel4" runat="server">
    <ContentTemplate>
    <fieldset>
    <legend>Detalle</legend>

        <asp:GridView ID="gvDetalle" runat="server" CellPadding="4" ForeColor="#333333" 
            GridLines="None" AutoGenerateColumns="False" Width="478px" 
            DataKeyNames="IdProducto" 
            onselectedindexchanged="gvDetalle_SelectedIndexChanged" 
            onrowcommand="gvDetalle_RowCommand">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:BoundField DataField="NomCompleto" HeaderText="Descripción" />
                <asp:BoundField DataField="Cantidad" HeaderText="Cantidad" />
                <asp:BoundField DataField="Precio" HeaderText="Precio" 
                    DataFormatString="{0:c}" />
                <asp:TemplateField HeaderText="Monto">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("monto") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="lblTotalGrid" runat="server">S/. 0,00</asp:Label>
                        </FooterTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("monto", "{0:c}") %>'></asp:Label>
                        </ItemTemplate>
                </asp:TemplateField>
                <asp:CheckBoxField DataField="Activo" HeaderText="Activo" />
                     <asp:ButtonField ButtonType="Button" CommandName="Quitar" Text="Quitar" />
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>

    </fieldset>
    </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnAgregar" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>

<!-- ####################################### -->

    <asp:Panel ID="Panel1" runat="server" CssClass="CajaDialogo">
        <asp:UpdatePanel ID="UpdatePanel5" runat="server">
        <ContentTemplate>
        <fieldset>
        <legend>Producto</legend>

            Descripción:
            <asp:TextBox ID="txtProductoBusca" runat="server"></asp:TextBox>
            <asp:Button ID="btnProductoBusca" runat="server" Text="Buscar" />

        </fieldset>

        <asp:GridView ID="gvProducto" runat="server" CellPadding="4" ForeColor="#333333" 
                GridLines="None" AllowPaging="True" AutoGenerateColumns="False" 
                DataKeyNames="Id" DataSourceID="ObjectDataSource1" 
                onselectedindexchanged="gvProducto_SelectedIndexChanged" PageSize="5" 
                Width="480px">
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <Columns>
                    <asp:CommandField ShowSelectButton="True" />
                    <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
                    <asp:BoundField DataField="Descripcion" HeaderText="Descripcion" 
                        SortExpression="Descripcion" />
                    <asp:BoundField DataField="Stock" HeaderText="Stock" SortExpression="Stock" />
                    <asp:BoundField DataField="Precio" HeaderText="Precio" 
                        SortExpression="Precio" />
                </Columns>
                <EditRowStyle BackColor="#999999" />
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#E9E7E2" />
                <SortedAscendingHeaderStyle BackColor="#506C8C" />
                <SortedDescendingCellStyle BackColor="#FFFDF8" />
                <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
            </asp:GridView>
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                SelectMethod="BuscarProductoPorNombre" TypeName="BL.ProductoBL">
                <SelectParameters>
                    <asp:ControlParameter ControlID="txtProductoBusca" DefaultValue="%" 
                        Name="nombre" PropertyName="Text" Type="String" />
                </SelectParameters>
            </asp:ObjectDataSource>
        </ContentTemplate>
            
        </asp:UpdatePanel>
        <br />
            <asp:Button ID="btnProductoCerrar" runat="server" Text="Cerrar" />
    </asp:Panel>
    <br />
<!-- ####################################### -->

     <asp:ModalPopupExtender ID="Panel1_ModalPopupExtender" runat="server" 
        Enabled="True" 
        TargetControlID="btnBuscarProducto" 
        PopupControlID="Panel1"
        BackgroundCssClass="FondoAplicacion"
        OkControlID="btnProductoCerrar"
        >
    </asp:ModalPopupExtender>
    
<!-- ####################################### -->

    <asp:Panel ID="Panel2" runat="server" CssClass="CajaDialogo" Visible="False">
        <asp:UpdatePanel ID="UpdatePanel6" runat="server" Visible="False">
            <ContentTemplate>
                <fieldset>
            <legend>Empleado</legend>

                    Ingrese Nombre:

                    <asp:TextBox ID="txtEmpleadoBusca" runat="server"></asp:TextBox>
                    <asp:Button ID="btnEmpleadoBusca" runat="server" Text="Buscar" />

            </fieldset>
                <br />
                <asp:GridView ID="gvEmpleado" runat="server" AllowPaging="True" 
                    AutoGenerateColumns="False" CellPadding="4" DataKeyNames="Id" 
                    DataSourceID="ObjectDataSource2" ForeColor="#333333" GridLines="None" 
                    PageSize="5" Width="562px" 
                    onselectedindexchanged="gvEmpleado_SelectedIndexChanged">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
                        <asp:BoundField DataField="NombreCompleto" HeaderText="Nombre " 
                            ReadOnly="True" SortExpression="NombreCompleto" />
                        <asp:BoundField DataField="Direccion" HeaderText="Direccion" 
                            SortExpression="Direccion" />
                        <asp:BoundField DataField="Dni" HeaderText="Dni" SortExpression="Dni" />
                        <asp:BoundField DataField="Telefono" HeaderText="Telefono" 
                            SortExpression="Telefono" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
                <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
                    SelectMethod="BuscarEmpleadoPorNombre" TypeName="BL.EmpleadoBL">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="txtEmpleadoBusca" DefaultValue="%" 
                            Name="nombre" PropertyName="Text" Type="String" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnEmpleado" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
        <br />
        <asp:Button ID="btnEmpleadoCerrar" runat="server" Text="Cerrar" />                
    </asp:Panel>
    <br />
<!-- ####################################### -->

     <asp:ModalPopupExtender ID="Panel2_ModalPopupExtender" runat="server" 
        Enabled="True" 
        TargetControlID="btnEmpleado" 
        PopupControlID="Panel2"
        BackgroundCssClass="FondoAplicacion"
        OkControlID="btnEmpleadoCerrar"
        >
    </asp:ModalPopupExtender>

<!-- ####################################### -->

    <asp:Panel ID="Panel3" runat="server" CssClass="CajaDialogo">
            <asp:UpdatePanel ID="UpdatePanel7" runat="server">
                <ContentTemplate>
            <fieldset>
            <legend>Proveedor</legend>

                Ingrese Razon Social:&nbsp;
                <asp:TextBox ID="txtProveedorBusca" runat="server"></asp:TextBox>
                <asp:Button ID="btnProvedorBusca" runat="server" Text="Buscar" />

            </fieldset>

                    <br />
                    <asp:GridView ID="gvProveedor" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="Id" 
                        DataSourceID="ObjectDataSource3" ForeColor="#333333" GridLines="None" 
                        onselectedindexchanged="gvProveedor_SelectedIndexChanged" PageSize="5" 
                        Width="552px">
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <Columns>
                            <asp:CommandField ShowSelectButton="True" />
                            <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
                            <asp:BoundField DataField="RazonSocial" HeaderText="Razon Social" 
                                SortExpression="RazonSocial" />
                            <asp:BoundField DataField="Ruc" HeaderText="Ruc" 
                                SortExpression="Ruc" />
                            <asp:BoundField DataField="Direccion" HeaderText="Direccion" 
                                SortExpression="Direccion" />
                            <asp:BoundField DataField="Telefono" HeaderText="Telefono" 
                                SortExpression="Telefono" />
                        </Columns>
                        <EditRowStyle BackColor="#999999" />
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <SortedAscendingCellStyle BackColor="#E9E7E2" />
                        <SortedAscendingHeaderStyle BackColor="#506C8C" />
                        <SortedDescendingCellStyle BackColor="#FFFDF8" />
                        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                    </asp:GridView>
                    <asp:ObjectDataSource ID="ObjectDataSource3" runat="server" 
                        SelectMethod="BuscarProveedorPorNombre" TypeName="BL.ProveedorBL">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="txtProveedorBusca" DefaultValue="%" 
                                Name="nombre" PropertyName="Text" Type="String" />
                        </SelectParameters>
                    </asp:ObjectDataSource>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnProveedor" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
            <br />
            <asp:Button ID="btnProveedorCerrar" runat="server" Text="Cerrar" />
        </asp:Panel>

<!-- ####################################### -->

     <asp:ModalPopupExtender ID="Panel3_ModalPopupExtender" runat="server" 
        Enabled="True" 
        TargetControlID="btnProveedor" 
        PopupControlID="Panel3"
        BackgroundCssClass="FondoAplicacion"
        OkControlID="btnProveedorCerrar"
        >
    </asp:ModalPopupExtender>
     <br />
<!-- ####################################### -->

     <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
        Text="Cancelar" />
     
</asp:Content>
